package fch;

import static org.junit.Assert.assertTrue;
import robocode.control.events.TurnEndedEvent;
import robocode.control.snapshot.IRobotSnapshot;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that CrazyTracker's tracking algorithm allows for accurate firing as it moves around
 * randomly.
 * @author Christopher Foo
 *
 */
public class TestTracking extends RobotTestBed {

  @Override
  /**
   * Check to see if CrazyTracker's stays high.  It should never drop below 95 if the tracking
   * algorithm works and most of the bullets hit the target.
   * 
   * @param event Details about the finished turn.
   */
  public void onTurnEnded(TurnEndedEvent event) {
    IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1];
    assertTrue("Energy High from hitting", robot.getEnergy() > 95);
  }
  
  @Override
  /**
   * Use SittingDuck and the CrazyTracker for this test.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  public String getRobotNames() {
    return "sample.SittingDuck,fch.CrazyTracker";
  }
  
  /**
   * This test runs for 10 round.
   *
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  @Override
  /**
   * If the robots should start in the same positions for each round.
   * 
   * @return If the robots should start in the same positions for each round.
   */
  public boolean isDeterministic() {
    return true;
  }
  
  @Override
  /**
   * Specify the starting positions of the robots.
   * 
   * @return A comma delimited string of each robot's x-position, y-position, and heading.
   */
  public String getInitialPositions() {
    return "400, 300, 90, 0, 0, 0";
  }
}
